package com.yanqu.road.server.manger.config.grandchild.talent.enums;

import com.yanqu.road.entity.enums.eSkillType;
import com.yanqu.road.server.manger.config.grandchild.talent.effect.*;
import com.yanqu.road.server.manger.config.grandchild.talent.entity.TalentTriggerSkillParam;
import com.yanqu.road.server.manger.config.grandchild.talent.entity.TalentTriggerSkillResult;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public enum eGrandChildSkillEffect {

    TYPE98(eSkillType.GrandChildSetQuality.getValue(), new SkillEffect98(), eGrandChildSkillEffectStage.CHOICE_TALENT),
    TYPE99(eSkillType.GrandChildQualityAdd.getValue(), new SkillEffect99(), eGrandChildSkillEffectStage.CHOICE_TALENT),
    TYPE100(eSkillType.GrandChildFlairChange.getValue(), new SkillEffect100(), eGrandChildSkillEffectStage.CHOICE_TALENT),
    TYPE101(eSkillType.GrandChildLevelLimitChange.getValue(), new SkillEffect101(), eGrandChildSkillEffectStage.CHOICE_TALENT),
    TYPE102(eSkillType.GrandChildTeachExpAddi.getValue(), new SkillEffect102(), eGrandChildSkillEffectStage.GRADUATION),
    TYPE103(eSkillType.GrandChildBaiYeExpAddi.getValue(), new SkillEffect103(), eGrandChildSkillEffectStage.GRADUATION),
    TYPE104(eSkillType.GrandChildPatronsAbilityAddi.getValue(), new SkillEffect104(), eGrandChildSkillEffectStage.UPGRADE),
    TYPE105(eSkillType.GrandChildUpgradeEarnAddi.getValue(), new SkillEffect105(), eGrandChildSkillEffectStage.UPGRADE),
    TYPE106(eSkillType.GrandChildUpgradeTriggerTop.getValue(), new SkillEffect106(), eGrandChildSkillEffectStage.UPGRADE),
    TYPE107(eSkillType.GrandChildUpgradeChangeOccupationFlair.getValue(), new SkillEffect107(), eGrandChildSkillEffectStage.UPGRADE),
    TYPE109(eSkillType.GrandChildExamAddEarnSpeed.getValue(), new SkillEffect109(), eGrandChildSkillEffectStage.EXAM),

    ;

    private static Map<Integer, eGrandChildSkillEffect> cacheMap = new ConcurrentHashMap<>();

    static {
        for (eGrandChildSkillEffect value : values()) {
            cacheMap.put(value.type, value);
        }
    }

    private int type;
    private ISkillEffect effect;
    private eGrandChildSkillEffectStage stage;

    eGrandChildSkillEffect(int type, ISkillEffect effect, eGrandChildSkillEffectStage stage) {
        this.type = type;
        this.effect = effect;
        this.stage = stage;
    }

    public static eGrandChildSkillEffect getByType(int type) {
        return cacheMap.get(type);
    }

    public eGrandChildSkillEffectStage getStage() {
        return stage;
    }

    public static TalentTriggerSkillResult getResult(TalentTriggerSkillParam param) {
        eGrandChildSkillEffect skillEffect = cacheMap.get(param.getSkillInfo().getType());
        return skillEffect.effect.getResult(param);
    }

}
